_ = require 'underscore'

MB_SIZE = 1024 * 1024

###*
 * [status description]
 * @param  {[type]}   req  [description]
 * @param  {[type]}   res  [description]
 * @param  {Function} next [description]
 * @return {[type]}        [description]
###
status = (req, res, next) ->
  memoryUsage = process.memoryUsage()
  _.each memoryUsage, (value, key) ->
    memoryUsage[key] = Math.floor(value / MB_SIZE) + 'MB'
  statusInfo = 
    argv : process.argv
    versions : process.versions
    NODE_ENV : process.env.NODE_ENV || 'development'
    pid : process.pid
    execPath : process.execPath
    memoryUsage : memoryUsage
    uptime : process.uptime()
  res.send JSON.stringify statusInfo
module.exports = 
  status : status